package com.syb.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestFilter implements Filter{

	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub
	}

	public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
			HttpServletRequest hrequest = (HttpServletRequest)request;
			HttpServletResponse hresponse = (HttpServletResponse)response;
			System.out.print("路径:"+hrequest.getRequestURI());
			/*if(!hrequest.getRequestURI().contains("/sys/login")){
				if(hrequest.getSession().getAttribute("userSession")==null){
					RequestDispatcher dispat = hrequest.getRequestDispatcher("/jsp/background/framework/login.jsp");
					dispat.forward(hrequest, hresponse);
					hresponse.sendRedirect(hrequest.getContextPath()+("/jsp/background/framework/login.jsp"));
					 * 
				    
				}
			}*/
				 chain.doFilter(hrequest, hresponse);	
			
	   
	}

	public void destroy() {
		// TODO Auto-generated method stub
		
	}

}
